<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="generator" content="macvim" />
<meta name="author" content="http://fisherhe.com (heqiang.org@gmail.com)" />
<title>AJAX-Demo</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js" type="text/javascript"></script>
</head>
<style type="text/css" media="screen">
#load {
	font-size:24px;
}	
#ajaxDemo {
	border:2px solid #f50;
	padding:10px;
	margin:10px;
	min-height:200px;
	font-size:1em;
}

</style>
<body>
<p>
<a href="#" id="load-a">A</a> <a href="#" id="load-b">B</a> <a href="#" id="load-c">C</a> <a href="#" id="load-d">D</a> <a href="#" id="load-y">Y</a>
<a href="#" id="load-e" >E</a>
</p>
<div id="ajaxDemo">
	hello!
</div>

<script type="text/javascript">
//load()
$("#load-a").click(function(){
	alert(".load()");
	$("#ajaxDemo").load("a.html");
	return false;
});


//.getJSON()
$("#load-b").click(function(){
	$.getJSON("b.json",function(data){
		$("#ajaxDemo").empty();
		alert(".getJSON()");
		$.each(data,function(entryIndex,entry){
			alert("111");
			var html = '<div class="entry"><ul>';
			html += '<h3 class="term">' + entry['term'] + '</h3>';
			html += '<li class="part">' + entry['part'] + '</li>';
			html += '<li class="definition">' + entry['definition'] + '</li>';
			if(entry['quote']){
				html += '<li class="quote">'
				$.each(entry['quote'],function(lineIndex,line){
					html += '<span class="quote-line">' + line + '</span>';		
				});
				html += '</li>';
			}
			if(entry['author']){
				html += '<li class="quote-author">' + entry['author'] + '</li>';
			}
			html += '</ul></div>';
			$("#ajaxDemo").append(html);
			alert(html);
		});
	});
	return false;	
});


$("#load-y").click(function(){
	console.log("111");
	//url = "http://api.paipai.com/shop/getShopCategoryList.xhtml?charset=uft-8&format=json&pureData=1&sellerUin=855001818&jsoncallback=?",
	$.getJSON("http://api.paipai.com/shop/getShopCategoryList.xhtml?charset=uft-8&format=json&pureData=1&sellerUin=855001818&jsoncallback=?",
	//$.getJSON("list.js",
		function(data){
		$("#ajaxDemo").empty();
		console.log("222");
		alert(data);
		/*
		$.each(data.shopCategoryList,function(i,list){
			var html = '<li>' + list.desc + '</li>';
			$("#ajaxDemo").append(html);
		});
		*/
	});
});


//.getScript()
$("#load-c").click(function(){
	alert(".getScript()");
	$.getScript("c.js");
	return false;
});

//get()
$("#load-d").click(function(){
	alert(".get()");
	$.get("d.xml",function(data){
		$("#ajaxDemo").empty();
		$(data).find("entry:has(quote[author])").each(function(){
			var $entry = $(this);
			//alert($entry.find("definition").text());
			var html = '<div class="entry">';
			html += '<h3 class="term">' + $entry.attr('term') + '</h3>';
			html += '<ul><li>' + $entry.attr('part') + '</li>';
			//html += $entry.find("definition").text();
			html += "</ul></div>"
			$("#ajaxDemo").append(html);
			alert(html);
		});
	});
});

//feed
$("#load-e").click(function(){	
//	$("#ajaxDemo").empty();
	$("#ajaxDemo").each(function(){
		var $ajaxDemo = $(this);
		$ajaxDemo.empty();
		alert("00");
		$.get("feed.xml",function(data){
			$("rss channel item",data).each(function(){
				var $links = $("<a></a>").attr("href",$("link",this).text())
				.text($("title",this).text());
				
				var $title = $("<h4></h4>").append($links);
				var $des = $("<p></p>").text($("description",this).text());
				var $list = $("<div class='feedlist'></div>").append($title,$des);


				$list.appendTo($ajaxDemo);
				//alert($ulist);
			});
		});
	});

/*
	$.get("feed.xml",function(data){
		$(data).find("channel").each(function(){
			alert("ok");
			var $channel = $(this);
			var html = '<h4>';

			html += $('title',this).text();
			html += '</h4>';
			$channel.each(function(){
				$title = '<h4>' + $(this).find("title").text()  + '</h4>';
				alert($title);
			});
			$("#ajaxDemo").append(html);
		});
	});
*/


});


</script>



</body>
</html>
